from google.appengine.ext import db

from model.user import User
from model.room import Room



class Message(db.Model):
    """Text message sent between users."""
    
    sender = db.ReferenceProperty(User, required=True)
    recipients = db.ListProperty(db.Key, required=True)
    room = db.ReferenceProperty(Room, required=True)
    # Not using StringProperty, because it can have more than 500 characters.
    content = db.TextProperty(required=True)
    insert_time = db.DateTimeProperty(required=True, auto_now_add=True)
    
    def __str__(self):
        return "Message + \"" + self.content + "\""